<extend name="Public/base" />

<block name="body">
    <!-- 标题栏 -->
    <div class="main-title">
        <h2>用户管理列表</h2>
    </div>
    <div class="cf">
        <!-- 高级搜索 -->
        <div class="search-form fr cf">
            <div class="sleft">
                <select name="is_agent" id="is_agent">
                    <option value="-1" <if condition="$is_agent eq -1">selected</if>  style="width:200px">是否为经纪人</option>
                    <option value="1" <if condition="$is_agent eq 1">selected</if>  style="width:200px">是</option>
                    <option value="2" <if condition="$is_agent eq 2">selected</if>  style="width:200px">否</option>
                </select>
            </div>
            <div class="sleft">
                <input type="text" name="nickname" class="search-input" value="{:I('nickname')}" placeholder="昵称">
            </div>
            <div class="sleft">
                <input type="text" name="mobile" class="search-input" value="{:I('mobile')}" placeholder="电话号码">
            </div>
            <div style = "float:left;line-height:30px;">从</div>
            <div class="sleft">
                <input type="text" id="begin_time" name="begin_time" class="search-input" value="{:I('begin_time')}" placeholder="起始时间">
            </div>
            <div style = "float:left;line-height:30px;margin-right:10px;">至</div>
            <div class="sleft">
                <input type="text" id="end_time" name="end_time" class="search-input" value="{:I('end_time')}" placeholder="结束时间">
            </div>
            <div style = "float:left;line-height:30px;margin-left:-10px;margin-right:10px;">关注</div>
            <div class="sleft">
                <a class="sch-btn" href="javascript:;" id="search" url="{:U('index')}"><i class="btn-search"></i></a>
            </div>
        </div>
    </div>
    <!-- 数据列表 -->
    <div class="data-table table-striped">
        <table class="">
            <thead>
            <tr>
                <th class="row-selected row-selected"><input class="check-all" type="checkbox"/></th>
                <th class="">ID</th>
                <th class="">用户上级</th>
                <th class="">昵称</th>
                <th class="">经纪人</th>
                <th class="">电话</th>
                <th class="">上次登录</th>
                <th class="">关注时间</th>
                <th class="">余额</th>
                <!--<th class="">类型</th>-->
                <th class="">操作</th>
            </tr>
            </thead>
            <tbody>
            <notempty name="list">
                <volist name="list" id="vo">
                    <tr>
                        <td><input class="ids" type="checkbox" name="ids[]" value="{$vo.id}" /></td>
                        <td>{$vo.id}</td>
                        <td>{$vo.topname}{$vo.maker_id}</td>
                        <td>{$vo.nickname}<if condition="$vo['maker_id'] eq 0 "><font color="red">(模拟)</font></if></td>
                        <td><if condition="$vo.is_agent eq 1">是<else/>否</if></td>
                        <td>{$vo.mobile}</td>
                        <td>{$vo.login_time|time_format}</td>
                        <td>{$vo.subscribe_time|time_format}</td>
                        <td>{$vo.money}</td>
                        <!--<td>{$vo.type}</td>-->
                        <td>
                            <a href="{:U('FuturesUser/edit?id='.$vo['id'])}">编辑</a>
                            <a href="{:U('FuturesUser/bank?id='.$vo['id'])}">查看银行卡</a>
                            <a href="{:U('FuturesUser/record?id='.$vo['id'])}">账户资金</a>
                            <a href="{:U('FuturesUser/level?id='.$vo['id'])}">查看下级</a>
                            <?php	$agent = M('Futures_agent')->where('user_id='.$vo[id])->find();?>
                            <if condition="$agent['pt_role'] eq 1">
                            	<a href="{:U('FuturesUser/agent?id='.$vo['id'])}">代理商编辑</a>
                            <elseif condition="$agent['pt_role'] eq 2"/>
                                <a href="{:U('FuturesUser/agent?id='.$vo['id'])}">做市商编辑</a>
                            <else/>
                            	<a href="{:U('FuturesUser/agent?id='.$vo['id'])}">开设用户角色</a>
                            </if>
                            <a href="{:U('FuturesFundSummary/index',array('id'=>$vo['id']))}">资金汇总</a>
                            <a href="{:U('FuturesFundSummary/index?id='.$vo['id'])}">查看资金明细</a>

                        </td>
                    </tr>
                </volist>
                <else/>
                <td colspan="9" class="text-center"> aOh! 暂时还没有内容! </td>
            </notempty>
            </tbody>
        </table>
    </div>
    <div class="page">
        {$show}
    </div>
</block>

<block name="script">
    <link href="__STATIC__/datetimepicker/css/datetimepicker.css?v={:SITE_VERSION}" rel="stylesheet" type="text/css">
    <php>if(C('COLOR_STYLE')=='blue_color') echo '<link href="__STATIC__/datetimepicker/css/datetimepicker_blue.css?v={:SITE_VERSION}" rel="stylesheet" type="text/css">';</php>
    <link href="__STATIC__/datetimepicker/css/dropdown.css?v={:SITE_VERSION}" rel="stylesheet" type="text/css">
    <script type="text/javascript" src="__STATIC__/datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
    <script type="text/javascript" src="__STATIC__/datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js?v={:SITE_VERSION}" charset="UTF-8"></script>
    <script src="__STATIC__/thinkbox/jquery.thinkbox.js?v={:SITE_VERSION}"></script>
    <script type="text/javascript">
        $('#begin_time,#end_time,#create_time').datetimepicker({
            format: 'yyyy-mm-dd',
            language:"zh-CN",
            minView:2,
            autoclose:true,
        });
        //搜索功能
        $("#search").click(function(){
            var url = $(this).attr('url');
            url = url.substr(0,url.lastIndexOf('.'));
            var query  = $('.search-form').find('input').serialize();
            var is_agent=$('#is_agent').val();
            query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g,'');
            query = query.replace(/^&/g,'');
            query+="/is_agent/"+is_agent;
            query = query.replace(/=/gm,"/");
            query = query.replace(/&/gm,"/");

            if( url.indexOf('?')>0 ){
              if(query.substr(0,1) != "/"){
                url += "/"+query;
              }else{
                url += query;
              }
            }else{
                url += "/" + query;
            }
            //alert(url);
            window.location.href = url;
        });
        //回车搜索
        $(".search-input").keyup(function(e){
            if(e.keyCode === 13){
                $("#search").click();
                return false;
            }
        });
        //导航高亮
        $('.side-sub-menu').find('a[href="{:U('FuturesUser/index')}"]').closest('li').addClass('current');
    </script>
</block>
